<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	session.setAttribute("basePath", basePath);
%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<base href="${basePath }">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="description" content="">
<meta name="author" content="">
<title>西普茗茶商品-发表留言</title>
<meta name="renderer" content="webkit">

<!-- BEGIN GLOBAL MANDATORY STYLES -->
<link href="https://cdn.bootcss.com/font-awesome/4.0.3/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="assets/plugins/uniform/css/uniform.default.css" rel="stylesheet" type="text/css" />
<link href="assets/css/animate.css" rel="stylesheet" type="text/css" />
<!-- END GLOBAL MANDATORY STYLES -->
<!-- BEGIN PAGE LEVEL STYLES -->
<link href="https://cdn.bootcss.com/Swiper/3.0.8/css/swiper.min.css" rel="stylesheet" type="text/css" />
<!-- END PAGE LEVEL STYLES -->
<!-- BEGIN THEME STYLES -->
<link href="assets/css/style-metronic.css" rel="stylesheet" type="text/css" />
<link href="assets/css/style.css" rel="stylesheet" type="text/css" />
<link href="assets/css/style-responsive.css" rel="stylesheet" type="text/css" />
<link href="assets/css/plugins.css" rel="stylesheet" type="text/css" />
<link href="assets/css/themes/light.css" rel="stylesheet" type="text/css" id="style_color" />
<link href="assets/css/print.css" rel="stylesheet" type="text/css" media="print" />
<link href="assets/css/custom.css" rel="stylesheet" type="text/css" />
<link href="assets/css/pages/blog.css" rel="stylesheet" type="text/css" />
<link href="css/iconfont.css" rel="stylesheet" type="text/css" />
<!-- END THEME STYLES -->
<link rel="shortcut icon" href="favicon.ico" />

<script type="text/javascript">
	var isHTML5 = true;
</script>
<!--[if lt IE 9]>
    <script src="https://cdn.bootcss.com/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
	<script src="js/excanvas.min.js"></script> 
    <script type="text/javascript">
		isHTML5 = false;
	</script>
<![endif]-->

</head>
<!--/head-->
<!-- BEGIN BODY -->
<body class="page-footer-fixed">
	<div class="clearfix "></div>
	<!-- BEGIN CONTAINER -->
	<div class="page-container">
		<!-- BEGIN CONTENT -->
		<div class="page-content-wrapper">
			<div class="page-content no-space" style="margin-bottom: 50px !important;">

				<div class="blog-page">

					<div class="container">
						<div class="row margin-top-20">
							<div class="col-xs-12">
								<div class="media padding-top-5">
									<div class="media-body">
										<h5 class="media-heading">
											<span>${goods.goodsName }</span>
										</h5>
										<p class="margin-top-5">
											<span class="text-light">价格：</span><span class="text-red"><strong><i class="fa fa-rmb"></i> <fmt:formatNumber value="${goods.goodsPrice }" type="currency" pattern="#,##0.##" /></strong></span>
										</p>
										<p class="text-light">
											<c:if test="${goods.goodsTips!=null }">
											${goods.goodsTips }
											</c:if>
										</p>
										<div class="clearfix"></div>
									</div>
								</div>
							</div>
						</div>

						<div class="row margin-top-20">
							<div class="col-xs-12">
								<textarea maxlength="400" id="messageContent" class="form-control" rows="2" placeholder="亲，对商品有什么疑问？留言给客服吧！(5~400字)" data-regex="^\S.{3,398}\S$"></textarea>
							</div>
						</div>

						<br>
						<button id="submit_post_message_button" type="button" class="btn btn-lg blue btn-block" data-goods-id="${goods.goodsId }">提交留言</button>
					</div>
					<br>
				</div>
			</div>
		</div>
		<!-- END CONTAINER -->
	</div>
	<!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
	<!-- BEGIN CORE PLUGINS -->
	<script src="https://cdn.bootcss.com/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
	<script src="https://cdn.bootcss.com/jquery-migrate/1.2.1/jquery-migrate.min.js" type="text/javascript"></script>
	<!-- IMPORTANT! Load jquery-ui-1.10.3.custom.min.js before bootstrap.min.js to fix bootstrap tooltip conflict with jquery ui tooltip -->
	<script src="assets/plugins/jquery-ui/jquery-ui-1.10.3.custom.min.js" type="text/javascript"></script>
	<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js" type="text/javascript"></script>
	<script src="assets/plugins/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js" type="text/javascript"></script>
	<script src="assets/plugins/jquery-slimscroll/jquery.slimscroll.min.js" type="text/javascript"></script>
	<script src="assets/plugins/jquery.blockui.min.js" type="text/javascript"></script>
	<script src="assets/plugins/jquery.cokie.min.js" type="text/javascript"></script>
	<script src="assets/plugins/uniform/jquery.uniform.min.js" type="text/javascript"></script>
	<script src="js/wow.min.js"></script>
	<script src="js/bootstrap.file-input.js"></script>
	<!-- END CORE PLUGINS -->
	<!-- BEGIN PAGE LEVEL PLUGINS -->
	<script type="text/javascript" src="https://cdn.bootcss.com/Swiper/3.0.8/js/swiper.jquery.min.js"></script>
	<script type="text/javascript" src="assets/plugins/jquery-validation/dist/jquery.validate.min.js"></script>
	<script type="text/javascript" src="assets/plugins/jquery-validation/localization/messages_zh.js"></script>
	<script type="text/javascript" src="assets/plugins/select2/select2.min.js"></script>
	<script type="text/javascript" src="assets/plugins/jquery-bootpag/jquery.bootpag.min.js"></script>
	<script type="text/javascript" src="js/jquery.form.js"></script>
	<!-- END PAGE LEVEL PLUGINS -->
	<!-- BEGIN PAGE LEVEL SCRIPTS -->
	<script src="js/app.js"></script>
	<!-- END PAGE LEVEL SCRIPTS -->

	<script>
		$(function()
		{
			// Initiat WOW JS
			if (isHTML5 == true)
			{
				new WOW().init();
			}
			App.init();

			$("#submit_post_message_button").click(function()
			{
				var tips = "";
				var tips_number = 1;
				$("textarea[data-regex]").each(function(i, dom)
				{
					var n = $(dom);
					if (new RegExp(n.attr("data-regex")).test(n.val()) == false)
					{
						tips += tips_number++ + " . \"" + n.val() + "\" 不满足输入要求;\n";
					}
				});

				if (tips.length > 0)
				{
					alert(tips + "\n请检查一下重新输入.");
					return false;
				}

				var goods_id = $(this).attr("data-goods-id");
				var content = $("#messageContent").val();

				var submit_post_message_button_html = $("#submit_post_message_button").html();
				$.ajax(
				{
					url : "u_post_message_do",
					type : "POST",
					dataType : "json",
					beforeSend : function(XMLHttpRequest)
					{
						$("#submit_post_message_button").attr("disabled", "disabled");
						$("#submit_post_message_button").html("正在提交留言信息中...");
					},
					data :
					{
						'goodsId' : goods_id,
						'content' : content
					},
					success : function(json, textStatus)
					{
						if (json.success == true)
						{
							alert("发表留言成功了。在个人中心会收到客服的回复哦。");
							window.location.href = "item/" + goods_id;
						}
						else
						{
							alert(json.info);
						}
					},
					error : function(XMLHttpRequest, textStatus, errorThrown)
					{
						alert("提交失败，请仔细检查您的输入是否满足要求。");
					},
					complete : function(XMLHttpRequest, textStatus)
					{
						$("#submit_post_message_button").removeAttr("disabled");
						$("#submit_post_message_button").html(submit_post_message_button_html);
					}
				});
			});
		});
	</script>
	<!-- END JAVASCRIPTS -->
</body>
</html>